define(function(require, exports, module) {
	var _self = this;
	var utils = _u = {};
	/**
	 * 布尔类型转换
	 */
	_u.parseBool=function( _input ){
        if( typeof _input == 'string' ){
            _input = _input.replace( /[\s]/g, '' ).toLowerCase();
            if( _input && ( _input == 'false' 
                            || _input == '0' 
                            || _input == 'null'
                            || _input == 'undefined'
           )) _input = false;
           else if( _input ) _input = true;
        }
        return !!_input;
    }
	/**
	 * 字符串处理
	 */
	_u.str = {
		substringBefore: function(str, seperator) {
			return str.substring(0, str.indexOf(seperator));
		},
		substringBeforeLast: function(str, seperator) {
			return str.substring(0, str.lastIndexOf(seperator));
		},
		substringAfter: function(str, seperator) {
			return str.substring(str.indexOf(seperator) + seperator.length);
		},
		substringAfterLast: function(str, seperator) {
			return str.substring(str.lastIndexOf(seperator) + seperator.length);
		},
		contains: function(str, word) {
			return str.indexOf(word) > -1;
		},
		notContains: function(str, word) {
			return !this.contains(str, word);
		}
	};
	/**
	 * 数字处理
	 */
	_u.num={
			
	};
	_u.date = {
	        formatDate: function(value) {
	            if (typeof(value) == 'undefined' || $.trim(value) == '') {
	                return "";
	            }
	            return new Date(value).format("yyyy-MM-dd");
	        },
	        formatDateTime: function(value) {
	            if (typeof(value) == 'undefined' || $.trim(value) == '') {
	                return "";
	            }
	            return new Date(value).format("yyyy-MM-dd HH:mm:ss");
	        },
	        timestampToDate: function(timestamp,format) {//时间戳转换成日期格式
	    		var viewSelf = this;
	    		var timezone = 8;//时区
	            var time = new Date(parseInt(timestamp) + parseInt(timezone) * 60 * 60 * 1000);
	            var ymdhis = "";
	            ymdhis += time.getUTCFullYear() + "-";
	            ymdhis += (time.getUTCMonth()+1) + "-";
	            ymdhis += time.getUTCDate();
	            ymdhis += " " + time.getUTCHours() + ":";
	            ymdhis += time.getUTCMinutes() + ":";
	            ymdhis += time.getUTCSeconds();
	            return new Date(Date.parse(ymdhis.replace(/-/g, "/"))).format(format);
	        }

	    };
	/**
	 * 按钮
	 */
	_u.button = {
	        loading: function(name) {
	            var selector = name;
	            $(selector).button('loading');
	            setTimeout(function() {
	                $(selector).button('reset');
	            },
	            5000);
	        },
	        ban: function(selector) {
	            $(selector).button('loading');
	        },
	        reset: function(selector) {
	            $(selector).button('reset');
	        },
	        confirm: function(selector, func,msg) {
	            var $this = $(selector);
	            if (bootbox.confirm({
	                message: msg?msg:"确定要删除此条数据吗 ?",
	                buttons: {
	                    confirm: {
	                        label: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定",
	                        className: "btn-danger btn-sm"
	                    },
	                    cancel: {
	                        label: "<i class='ace-icon fa fa-times bigger-110'></i> 取消",
	                        className: "btn-warning btn-sm"
	                    }
	                },
	                callback: function(result) {
	                    func(result);
	                }
	            }));
	        }
	    };
	/**
	 * AJAX处理
	 */
	_u.ajax={
			
	}
	/**
	 * 金额处理
	 */
	_u.money={
			
	},
	/**
	 * 下载
	 */
	_u.downloadFile=function(url){
		var gotoLink = document.createElement('a');
		gotoLink.style.display = 'none';
		gotoLink.href = url;
	    document.body.appendChild(gotoLink);
	    gotoLink.click();
	    document.body.removeChild(gotoLink);
	}
	module.exports = utils;
});